@extends('steward.layout')
@section('css')
    <link rel="stylesheet" href="/static/css/steward/main/main.css?v=201710250000001">
@endsection

@section('content')
    <div class="container" id="main-content">
        <div class="app-sidebar">
            <div class="app-first-slider">
                <div class="logo-wrap">
                    <div class="logo"><img src="/static/images/steward/common/logo.png"></div>
                </div>
                <ul class="nav_list">
                    @foreach($left_menus as $l_k=>$l_m)
                        <li data-index="{{$l_k}}">
                            <a href="javascript:;">
                                <span><img src="{{$l_m['icon']}}"></span>
                                <span class="text">{{$l_m['name']}}</span>
                            </a>
                        </li>
                    @endforeach
                </ul>
            </div>
            <!--子菜单栏-->
            <div class="app-second-silder" >
                <ul class="second_list">
                    @foreach($left_menus as $l_k => $l_m)
                        @foreach($l_m['sub'] as $m_m)
                            <li class="sub-nav-{{$l_k}}" style="display: none;">
                                <a href="{{$m_m['link']}}" target="main-frame">
                                    <span>{{$m_m['name']}}</span>
                                </a>
                            </li>
                        @endforeach
                    @endforeach
                </ul>
            </div>
        </div>
        <div class="main-container">
            <div class="app-top-box">
                <div class="left-notice" style="display: none;">
                    <a href="javascript:;">
                        <span class="img-notice"><img src="/static/images/steward/common/notice.png"> </span>
                        <span class="order-notice"></span>
                    </a>
                </div>
                <div class="right-nav">
                    <ul class="right_list">
                        @if($pc_client == 0)
                        <li class="phone-text">
                            <a href="javascript:;"><span><img src="/static/images/steward/common/phone.png"></span></a>
                            <a href="javascript:;"><span class="curn-blue">下载手机版商管家</span></a>
                        </li>
                        @endif
                        <li>
                            <a href="javascript:;" class="num-notice" style="display: none;">
                                <span><img src="/static/images/steward/common/tongzhi.png"></span>
                                <span class="num">0</span>
                            </a>
                            <a href="javascript:;">
                                <span class="curn-blue"><b>{{$mallName}}</b>&nbsp;&nbsp; 欢迎您，{{$userName}} </span></a> | <a href="/lar/steward/logout?redirect_url={{$domain_name}}/lar/steward">注销
                            </a>
                        </li>
                        <!--<li>
                            <a href="javascript:;"><span>个人设置</span></a>
                        </li>
                        <li>
                            <a href="javascript:;"><span>载入权限</span></a>
                        </li>-->
                    </ul>
                </div>
            </div>

        </div>

        <div class="right-sidebar">
            <div class="main-cont">
                <iframe frameborder="0" id="main-frame" name="main-frame" width="100%" height="100%" ></iframe>
            </div>
        </div>

    </div>

@endsection

@section('js')

    <script>

        $(function(){

            var main_content_obj = $('#main-content');

            //调整iframe高度
            var wh = $(window).height();
            main_content_obj.css('height', (wh-61) + 'px');

            main_content_obj.find('div.app-second-silder').find('li').click(function () {
                main_content_obj.find('div.app-second-silder').find('li').removeClass('active').eq($(this).index()).addClass('active');
            });

            main_content_obj.find('ul.nav_list').find('li').click(function() {

                main_content_obj.find('ul.nav_list').find('li').removeClass('active').eq($(this).index()).addClass('active');
                main_content_obj.find('div.app-second-silder').find('li').hide();

                var sub_nav = $('li.sub-nav-' + $(this).attr('data-index'));
                sub_nav.show();
                sub_nav.eq(0).trigger('click');
                $('#main-frame').attr('src', sub_nav.eq(0).find('a').attr('href'));

                if (sub_nav.length > 1) {
                    main_content_obj.find('div.app-second-silder').show();
                    main_content_obj.find('div.right-sidebar').css('padding-left', '240px');
                } else {
                    main_content_obj.find('div.app-second-silder').hide();
                    main_content_obj.find('div.right-sidebar').css('padding-left', '120px');
                }

            });
            main_content_obj.find('ul.nav_list').find('li').eq(0).trigger('click');

        });


        /**
         * 刷新订单提醒通知(供PC客户端调取)
         * @param new_count int 新订单数量
         * @param remind_count int 催单数量
         * @param return_count int 退单数量
         */
        function count_fresh(new_count, remind_count, return_count) {

            var n_str = '';

            if (!E.isNum(new_count) || new_count < 0) {
                new_count = 0;
            }

            if (!E.isNum(remind_count) || remind_count < 0) {
                remind_count = 0;
            }

            if (!E.isNum(return_count) || return_count < 0) {
                return_count = 0;
            }

            if (new_count > 0) {
                n_str += '<span class="order-notice-s">您有'+ new_count +'条新订单</span>';
            }

            if (remind_count > 0) {
                n_str += '<span class="order-notice-s">您有'+ remind_count +'条催单</span>';
            }

            if (return_count > 0) {
                n_str += '<span class="order-notice-s">您有'+ return_count +'条退单</span>';
            }

            $('.order-notice').html(n_str);

            if (n_str == '') {
                $('.left-notice').hide();
                $('.num-notice').hide().find('.num').html(0);
            } else {
                $('.num-notice').show().find('.num').html(parseInt(new_count + remind_count + return_count));
                $('.left-notice').show();
            }

        }

        /**
         * 调取PC客户端执行打印
         * @param order_id int 订单号
         */
        function client_print(order_id) {

            E.ajax({
                type : 'post',
                url  : '/lar/steward/order/print_log',
                data : {
                    'bill_no' : order_id,
                    'device_site' : 1
                },
                dataType : 'json',
                success :function(o){

                }
            });

            window.external.order_print(order_id);

        }

    </script>

@endsection